#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
class Student{
public:
    string name;
    int chinese;
    int math;
    int english;
    int totalScore;
    Student(const string& n, int c, int m, int e) : name(n), chinese(c), math(m), english(e) {
        totalScore = c + m + e;
    }

    // 重载 << 运算符
    friend ostream& operator<<(ostream& os, const Student& s) {
        os << s.name << " " << s.chinese << " " << s.math << " " << s.english << " " << s.totalScore;
        return os;
    }

    // 重载 >> 
    friend istream& operator>>(istream& is, Student& s) {
        is >> s.name >> s.chinese >> s.math >> s.english;
        s.totalScore = s.chinese + s.math + s.english;
        return is;
    }

    // 重载 < 运算
    bool operator<(const Student& other) const {
        if (totalScore!= other.totalScore) {
            return totalScore > other.totalScore;
        } else if (chinese!= other.chinese) {
            return chinese > other.chinese;
        } else if (math!= other.math) {
            return math > other.math;
        } else {
            return name < other.name;
        }
    }
};

int main(){
    int n;
    cin >> n;
    vector<Student> students;
    for (int i = 0; i < n; ++i) {
        Student s("", 0, 0, 0);
        cin >> s;
        students.push_back(s);
    }
    int k;
    cin >> k;
    sort(students.begin(), students.end());
    cout << students[k - 1].name << " " << students[k - 1].totalScore << endl;
    return 0;
}